<!doctype html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            无标题文档
        </title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <link rel="stylesheet" href="css/jquery.mobile-1.4.2.min.css" />
        <link rel="stylesheet" type="text/css" href="css/mobiscrollcss/mobiscroll.custom-2.6.2.min.css">
        <link rel="stylesheet" type="text/css" href="css/jkcss.css">
        <script type="text/javascript">
            document.location.href.split("#").length > 1 && (top.location = "delivery.html");
        </script>
        <script type="text/javascript" src="js/lib/jquery-2.1.1.min.js">
        </script>
        <script src="js/mobiscroll.custom-2.6.2.min.js">
        </script>
        <script type="text/javascript" src="js/JKLogin.js">
        </script>
        <script type="text/javascript" src="js/JKCheckForm.js">
        </script>
        <script type="text/javascript" src="js/JKFunc.js">
        </script>
        <script type="text/javascript" src="js/JKRegister.js">
        </script>
        <script type="text/javascript" src="js/lib/jquery.mobile-1.4.2.min.js">
        </script>
        <script type="text/javascript" src="js/JKAlgorithm.js?v=20140907">
        </script>
        <script type="text/javascript">
        function messageBox(str) {
            alert(str);
        }
        function debugLog(str) {
            console.log(str);
        }

            var storage;
            var shopId;
            var loginName;
			var telArr;
            window.onload = function() {
                storage = window.localStorage;
				window.telArr = new Array(storage.getItem("telPhones"));
                window.subAdminId = localStorage.getItem("subAdminId");
                window.shopId = localStorage.getItem("shopid");
                if (window.subAdminId == null) {
                	if("undefined" != typeof (mobile)){
						mobile.logout();
					}
                    top.location = "index.html";
                    return;
                }
                if("undefined" != typeof (mobile)){
                	mobile.login(storage.getItem("LoginName"));
                }
				getLastTime();
                go212();
            }

            function changePage(newPageID) {
                $(newPageID).trigger('create');
                $(newPageID+' ul').listview();
                $(newPageID+' ul').listview('refresh');
                $.mobile.changePage(newPageID, {
                    transition: "slide"
                });
            }
function getLastTime(){
	JKjsonP({
			ws:"merchants/getLastTime",
			parameter:{shopId:window.shopId},
			sFunc:function(json){
				if (json.result=="success"){
					var lastTime = json.data.lastTime;
					var serverTime = json.data.serverTime;
					$("#lastTime62").html(lastTime);
					var last = new Date(lastTime);
					var now = new Date(serverTime);
					if(last.getTime()-now.getTime() < 0){
						alert("您的使用期限已过，请续费后继续使用");
						localStorage.clear();
						localStorage.setItem("telPhones",window.telArr);
						window.location="index.html";
					}else if(last.getTime()-now.getTime() <= 259200000){
						alert("您的使用期限还剩下不到"+((last.getTime()-now.getTime())/86400000).toFixed(0)+"天，过期后将不能使用此软件，请及时续费");
					}
					}
			},
			eFunc:function(XMLHttpRequest, textStatus, emessage){
				JKPprompt("#popup14",emessage);
			}
		});
}
            function getData() {
                canJisuan = false;
                $('#page_2_1_2_list').html('<li data-role="list-divider"><div class="ui-grid-a"><div class="ui-block-a"align="left"><a id="shuaxin" style="font-size:16px; color:#00547b;" href="javascript:void(0);">刷新</a></div><div class="ui-block-b"align="right"><a href="javascript:void(0)"id="jisuan"style=" font-size:16px; color:#00547b; font: \'黑体\';">计算送货顺序</a></div></div></li>');
                $('#page_2_1_2_list').trigger('create');
                $('#page_2_1_2_list').listview('refresh');
                JKjsonP({
                    ws: "merchants/listDeliveryOrder2",
                    parameter: {
                        id: localStorage.getItem("subAdminId")
                    },
                    sFunc: function(json) {
                        if (json.result == "success") {
                            arr[0] = new Array(); // 队列
                            arr[1] = new Array(); // 可发货
                            arr[2] = new Array(); // 配送中
                            arr[3] = new Array(); // 交易成功
                            arr[4] = new Array(); // 交易失败
                            // json = {"result":"success","msg":"结果","data":[{"orderId":2,"shopSubAdminId":31,"nickName":"Jack","startTime":18,"endTime":19,"address":{"class":"com.jkstore.CustomerAddress","id":1,"address":"abcd","customer":{"class":"Customer","id":1},"lat":11,"lng":22},"status":2,"totalPrice":130},{"orderId":124,"shopSubAdminId":31,"nickName":"Jack","startTime":9,"endTime":10,"address":{"class":"com.jkstore.CustomerAddress","id":1,"address":"abcd","customer":{"class":"Customer","id":1},"lat":11,"lng":22},"status":1,"totalPrice":130},{"orderId":122,"shopSubAdminId":31,"nickName":"Jack","startTime":9,"endTime":10,"address":{"class":"com.jkstore.CustomerAddress","id":1,"address":"abcd","customer":{"class":"Customer","id":1},"lat":11,"lng":22},"status":1,"totalPrice":130},{"orderId":265,"shopSubAdminId":31,"nickName":"Jack","startTime":9,"endTime":10,"address":{"class":"com.jkstore.CustomerAddress","id":1,"address":"abcd","customer":{"class":"Customer","id":1},"lat":11,"lng":22},"status":2,"totalPrice":130},{"orderId":12,"shopSubAdminId":31,"nickName":"Jack","startTime":9,"endTime":10,"address":{"class":"com.jkstore.CustomerAddress","id":1,"address":"abcd","customer":{"class":"Customer","id":1},"lat":11,"lng":22},"status":2,"totalPrice":130},{"orderId":42,"shopSubAdminId":31,"nickName":"Jack","startTime":12,"endTime":13,"address":{"class":"com.jkstore.CustomerAddress","id":1,"address":"abcd","customer":{"class":"Customer","id":1},"lat":11,"lng":22},"status":2,"totalPrice":130},{"orderId":122,"shopSubAdminId":31,"nickName":"Jack","startTime":9,"endTime":10,"address":{"class":"com.jkstore.CustomerAddress","id":1,"address":"abcd","customer":{"class":"Customer","id":1},"lat":11,"lng":22},"status":2,"totalPrice":130}]};

                            var data = json.data;
                            for (var i = 0; i < data.length; i++) {
                                var obj = data[i];
                                if (obj.status == 1) {
                                    arr[0].push(obj);
                                } else if (obj.status == 2) {
                                    arr[1].push(obj);
                                } else if (obj.status == 3) {
                                    arr[2].push(obj);
                                }
                            }

                            go212UI(arr[2]);
                            go212UI(arr[1]);
                            go212UI(arr[0]);

                            // 刷新按钮
                            if (arr[2] != null && arr[2].length > 0) {
                                $('#shuaxin').unbind('click').css('color', '#00547b');
                            } else {
                                $('#shuaxin').bind('click',
                                function() {
                                    $('#shuaxin').trigger('create');
                                    go212();
                                }).css('color', '#00CC66');
                            }

                            // 计算按钮
                            if ((arr[2] == null || arr[2].length <= 0) && arr[1] != null && arr[1].length > 0) {
                                $('#jisuan').bind('click',
                                function() {
                                    jisuan();
                                }).css('color', '#00CC66');
                            } else {
                                $('#jisuan').unbind('click').css('color', '#00547b');
                            }

                            $('#page_2_1_2 ul').listview();
                            $('#page_2_1_2 ul').listview('refresh');
                        } else {
                            alert(json.msg);
                        }

                    },
                    eFunc: function(XMLHttpRequest, textStatus, emessage) {
                        alert("未知错误");
                        $('#shuaxin').bind('click',
                        function() {
                            $('#shuaxin').trigger('create');
                            go212();
                        }).css('color', '#00CC66');
                    }
                });
            }

            var canJisuan = false;
            var arr = new Array();
            var strArr = ['队列中', '可发货', '配送中'];

            var manCount = -1;
            function go212() {
                var finishFlag = false;
                JKjsonP({
                    ws: "merchants/getDeliveryManCount",
                    parameter: {
                        shopId: window.shopId
                    },
                    sFunc: function(json) {
                        if ("success" == json.result) {
                            if (json.data != manCount) {
                                debugLog("重新分配");
                                manCount = json.data;
                                calculate();
                            } else {
                                debugLog("直接计算");
                                getData();
                            }
                        }
                    },
                    eFunc: function(XMLHttpRequest, textStatus, emessage) {
                        messageBox("服务器解析数据错误");
                    }
                });

            }

            function calculate() {
                JKjsonP({
                    ws: "merchants/listTodayOrder",
                    parameter: {
                        shopId: window.shopId
                    },
                    sFunc: function(json) {
                        if ("success" == json.result) {
                            var orders = json.data;
                            listTodayOrder = json.data;

                            JKjsonP({
                                ws: "merchants/listVehicleCount",
                                parameter: {
                                    shopId: window.shopId
                                },
                                sFunc: function(json) {
                                    if ("success" == json.result) {
                                        JKjsonP({
                                            ws: "merchants/listDeliveryMan",
                                            parameter: {
                                                shopId: window.shopId
                                            },
                                            sFunc: function(json2) {
                                                debugLog("获取结果：" + JSON.stringify(json2));
                                                if ("success" == json2.result) {
                                                    
                                                    var deliveryManNum = json2.data;

                                                    if (deliveryManNum.length >= 1) {
                                                        var data = json.data;

                                                        var params = {
                                                            deliverymans: {
                                                                bike: data["1"],
                                                                electricMobile: data["2"],
                                                                car: data["3"]
                                                            }
                                                        };
                                                        deliverOrder = new DeliveryOrder(params);
                                                        
                                                        for (var i = 0; i < listTodayOrder.length; i++) {
                                                            listTodayOrder[i].distance = getDistance(listTodayOrder[i].lat, listTodayOrder[i].lng, window.lat, window.lng);
                                                            listTodayOrder[i].id = listTodayOrder[i].orderId
                                                        }

                                                        var newOrders = deliverOrder.calculateDeliveryOrder(new Date().getHours(), listTodayOrder);

                                                        if (newOrders.length <= 0) {
                                                            messageBox("分配失败");
                                                            return
                                                        }

                                                        var aaab = ["8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"];
                                                        var ttt = new Array();
                                                        for (var i = 0; i < 28; i++) {
                                                            var arr = newOrders[i];
                                                            if (arr != null) {
                                                                for (var j = 0; j < arr.length; j++) {
                                                                    var o = {
                                                                        orderId: arr[j].orderId,
                                                                        deliveryTime: parseInt(_getStdTime2(arr[j].shipStartTime) / 60)
                                                                    }
                                                                    ttt.push(o)
                                                                }
                                                            }
                                                        }
            
                                                        var deliveryMan = [];   
                                                        if (deliveryManNum.length > 1) {
                                                            var sum = 0;
                                                            for (var i = 0; i < deliveryManNum.length; i++) {
                                                                deliveryMan.push(deliveryManNum[i]);
                                                                sum += deliveryManNum[i];
                                                            }
                                                            
                                                            var oorr = listTodayOrder;
                                                            debugLog(oorr.length);
                                                            var sss = [];
                                                            for (var i = 0; i < oorr.length && i < sum; i++) {
                                                                oorr[i].id = oorr[i].orderId;
                                                                sss.push(oorr[i]);
                                                                debugLog(i);
                                                            }
                                                            debugLog(sss.length);

                                                            var sendData = new Array();
                                                            if (sss.length == 0) {
                                                                messageBox("没有订单");
                                                            } else{
                                                                var ddd = [];
                                                                if (sss.length == 1) {
                                                                    var timerss = new Array();
                                                                    var t22 = new Array();
                                                                    var tttt = new Array();
                                                                    for (var i = 0; i < sss.length; i++) {
                                                                        tttt.push({orderId:sss[i].orderId});
                                                                    }
                                                                    ddd = new Array();
                                                                    ddd.push(tttt);
                                                                } else {
                                                                    ddd = OrderDeliveryC(sss, sortOrders(sss), deliveryMan, sum);
                                                                    if (null == ddd) {
                                                                        messageBox("分配送货员失败");
                                                                        return;
                                                                    }
                                                                }
                                                                
                                                                for (var i = 0; i < ddd.length; i++) {
                                                                    var aaa = ddd[i];

                                                                    var index = i + 1;

                                                                    var timers = new Array();
                                                                    for (var j = 0; j < aaa.length; j++) {
                                                                        var oj = aaa[j];

                                                                        for (var k = 0; k < ttt.length; k++) {
                                                                            var ok = ttt[k];
                                                                            if (ok.orderId == oj.orderId) {
                                                                                if (null == timers[ok.deliveryTime]) {
                                                                                    timers[ok.deliveryTime] = new Array();
                                                                                }
                                                                                timers[ok.deliveryTime].push(oj.orderId);
                                                                                break;
                                                                            }
                                                                        }
                                                                    }
                                                                    var timerss = new Array();
                                                                    for (var ww = 0; ww < 24; ww++) {
                                                                        if (timers[ww] != null) {
                                                                            var wwo = {
                                                                                time: ww + 1,
                                                                                orders: timers[ww]
                                                                            };
                                                                            timerss.push(wwo);
                                                                        }
                                                                    }
                                                                    var doo = {
                                                                        id: index,
                                                                        times: timerss
                                                                    };
                                                                    sendData.push(doo);
                                                                }
                                                                

                                                                if (sendData.length <= 0) {
                                                                    messageBox("分配失败");
                                                                    return;
                                                                }

                                                                sendData = JSON.stringify(sendData);
                                                                debugLog(sendData);
                                                                JKjsonP({
                                                                    ws: "merchants/distributeOrder",
                                                                    parameter: {
                                                                        orders: sendData,
                                                                        shopId: window.shopId
                                                                    },
                                                                    sFunc: function(json) {
                                                                        if ("success" == json.result) {
                                                                            finishFlag = true;
                                                                            getData();
                                                                        } else {
                                                                            messageBox("分配失败");
                                                                        }
                                                                    },
                                                                    eFunc: function(XMLHttpRequest, textStatus, emessage) {
                                                                        messageBox("服务器返回错误");
                                                                    }
                                                                });
                                                                
                                                            }
                                                        } else if (1 == deliveryManNum.length) {
                                                            var sss = [];
                                                            var oorr = listTodayOrder;
                                                            for (var i = 0; i < oorr.length; i++) {
                                                                oorr[i].id = oorr[i].orderId;
                                                                sss.push(oorr[i]);
                                                                debugLog(i);
                                                            }

                                                            var sendData = [];
                                                            var ddd = [];
                                                            var timerss = new Array();
                                                            var t22 = new Array();
                                                            var tttt = new Array();
                                                            for (var i = 0; i < sss.length; i++) {
                                                                tttt.push({orderId:sss[i].orderId});
                                                            }
                                                            ddd = new Array();
                                                            ddd.push(tttt);
                                                            for (var i = 0; i < ddd.length; i++) {
                                                                var aaa = ddd[i];
                                                                var index = i + 1;

                                                                var timers = new Array();
                                                                for (var j = 0; j < aaa.length; j++) {
                                                                    var oj = aaa[j];
                                                                    for (var k = 0; k < ttt.length; k++) {
                                                                        var ok = ttt[k];
                                                                        if (ok.orderId == oj.orderId) {
                                                                            if (null == timers[ok.deliveryTime]) {
                                                                                timers[ok.deliveryTime] = new Array();
                                                                            }
                                                                            timers[ok.deliveryTime].push(oj.orderId);
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                                debugLog(timers);
                                                                var timerss = new Array();
                                                                for (var ww = 0; ww < 30; ww++) {
                                                                    if (timers[ww] != null) {
                                                                        debugLog(ww);
                                                                        var wwo = {
                                                                            time: ww,
                                                                            orders: timers[ww]
                                                                        };
                                                                        timerss.push(wwo);
                                                                    }
                                                                }
                                                                debugLog("timers");
                                                                debugLog(timerss);
                                                                var doo = {
                                                                    id: index,
                                                                    times: timerss
                                                                };
                                                                sendData.push(doo);
                                                            }
                                                            
                                                            if (sendData.length <= 0) {
                                                                messageBox("分配失败");
                                                                return;
                                                            }
                                                            sendData = JSON.stringify(sendData);

                                                            debugLog("发送数据");
                                                            debugLog(sendData);
                                                            JKjsonP({
                                                                ws: "merchants/distributeOrder",
                                                                parameter: {
                                                                    orders: sendData,
                                                                    shopId: window.shopId
                                                                },
                                                                sFunc: function(json) {
                                                                    if ("success" == json.result) {
                                                                        finishFlag = true;
                                                                        getData();
                                                                    } else {
                                                                        messageBox("分配失败");
                                                                    }
                                                                },
                                                                eFunc: function(XMLHttpRequest, textStatus, emessage) {
                                                                    messageBox("服务器返回错误");
                                                                }
                                                            });
                                                        } else {
                                                            messageBox("送货人数不足");
                                                        }
                                                    } else {
                                                        messageBox("送货人数不足");
                                                    }
                                                } else {
                                                    messageBox("获取送货员数量失败");
                                                }
                                            },
                                            eFunc: function(XMLHttpRequest, textStatus, emessage) {
                                                messageBox("服务器返回错误");
                                            }
                                        });
                                    } else {
                                        messageBox("获取交通工具数量失败");
                                    }
                                },
                                eFunc: function(XMLHttpRequest, textStatus, emessage) {
                                    messageBox("服务器解析数据错误");
                                }
                            });
                        }
                    },
                    eFunc: function(XMLHttpRequest, textStatus, emessage) {
                        messageBox("服务器解析数据错误");
                    },
                    cFunc: function() {
                    }
                });
            }

            function go212UI(tmpArr) {
                if (tmpArr != null && tmpArr.length > 0) {
                    var currentHour = new Date().getHours();
                    var fenzu = new Array();
                    for (var i = 0; i < tmpArr.length; i++) {
                        var obj = tmpArr[i];
						obj.shipStartTime = obj.shipStartTime.split(':')[0];
						obj.shipEndTime   = obj.shipEndTime.split(':')[0];
                        if (fenzu[obj.shipStartTime] == null) {
                            fenzu[obj.shipStartTime] = new Array()
                        }
                        fenzu[obj.shipStartTime].push(obj)
                    }
                    console.log(JSON.stringify(fenzu));
                    for (var i = 0; i < fenzu.length; i++) {
                        if (fenzu[i] != null && fenzu[i].length > 0) {
                            $('#page_2_1_2_list').append('<li data-role="list-divider"><div style="overflow:hidden;"><div class="ui-grid-a"><div class="ui-block-a"align="left"><h2>' + (i % 24) + '点-' + ((i + 1) % 24) + '点</h2></div><div class="ui-block-b"align="right"><h2 style="color:#00CC66">' + strArr[fenzu[i][0].status - 1] + '</h2></div></div></div></li>');
                            for (var j = 0; j < fenzu[i].length; j++) {
                                var obj = fenzu[i][j];
								var address = obj.address;
                                $('#page_2_1_2_list').append('<li><a href="javascript:void(0);"onClick="go221(' + obj.orderId + ')"data-transition="slide"><div class="ui-grid-a"style="font-size:20px"><div class="ui-block-a"><p>到货时间：' + obj.shipStartTime + '点-' + obj.shipEndTime + '点</p></div><div class="ui-block-b"align="right"><p>价格' + obj.totalPrice + '元</p></div><div class="ui-block-a"style="width:auto;margin-top:-20px"><p>到货地址：' + address[0] + '</p></div><div class="ui-block-a"style="width:auto;margin-top:-20px"><p>' + address[1] + '</p></div></div></a></li>')
                            }
                        }
                    }
                }
            }
            var jycgsb = [];
            function go142() {
                jycgsb = new Array();
                JKjsonP({
                    ws: "merchants/getTodayDeliveryOrder",
                    parameter: {
                        id: window.shopId
                    },
                    sFunc: function(json) {
                        if (json.result == "success") {
                            var o1 = json.data.successOrder;
                            var o2 = json.data.failureOrder;
                            $('#jycgList').html('');
                            for (var i = 0; i < o1.length; i++) {
                                var o = o1[i];
                                jycgsb.push(o);
                                var address = o.address.split(" ");
                                $('#jycgList').append('<li><a href="javascript:void(0)"onClick="go144(' + o.orderId + ', true)"data-transition="slide"><div class="ui-grid-a"style="font-size:20px;"><div class="ui-block-a"><p>到货时间：' + o.shipStartTime + '点-' + o.shipEndTime + '点</p></div><div class="ui-block-b"align="right"><p>预计' + o.totalPrice + '元</p></div><div class="ui-block-a"style="width:auto;margin-top:-20px"><p>到货地址：' + address[0] + '</p></div><div class="ui-block-a"style="width:auto;margin-top:-20px"><p>' + address[1] + '</p></div></div></a></li>');
                            }

                            $('#jysbList').html('');
                            for (var i = 0; i < o1.length; i++) {
                                var o = o1[i];
                                jycgsb.push(o);
                                var address = o.address.split(" ");
                                $('#jysbList').append('<li><a href="javascript:void(0)"onClick="go145(' + o.orderId + ', false)"data-transition="slide"><div class="ui-grid-a"style="font-size:20px;"><div class="ui-block-a"><p>到货时间：' + o.shipStartTime + '点-' + o.shipEndTime + '点</p></div><div class="ui-block-b"align="right"><p>预计' + o.totalPrice + '元</p></div><div class="ui-block-a"style="width:auto;margin-top:-20px"><p>到货地址：' + address[0] + '</p></div><div class="ui-block-a"style="width:auto;margin-top:-20px"><p>' + address[1] + '</p></div></div></a></li>');
                            }

                            changePage('#page_1_4_2')
                        } else {
                            alert(json.msg)
                        }
                    },
                    eFunc: function(XMLHttpRequest, textStatus, emessage) {
                        alert("未知错误")
                    }
                })
            }


            function go144(id) {
                var flag = false;
                for (var i = 0; i < jycgsb.length; i++) {
                    var o = jycgsb[i];
                    if (o.orderId == id) {
                        flag = true;
                        break;
                    }
                }
                if (!flag) {
                    alert("不存在该订单");
                    return;
                }

                JKjsonP({
                    ws: "merchants/getOrderDetail",
                    parameter: {
                        orderId: id
                    },
                    sFunc: function(json) {
                        if (json.result == "success") {
                            var o = json.data;
                            var address = o.address.split(' ');
                            $('#jycg144').html('<div class="ui-grid-a"><div class="ui-block-a"style="font-size:15px;width:auto"><p style="font-size:18px">交易成功</p></div><div class="ui-block-a"style="font-size:15px;width:auto"><p>订单号：'+o.orderNo+'</p></div><div class="ui-block-b"align="right"style="font-size:15px;"><p>预计：'+o.totalPrice+'元</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>下单时间：'+o.dateCreated+'</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>到货时间：'+o.arrivalStartTime+'点-'+o.arrivalEndTime+'点</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>手机号：'+o.mobilePhone+'</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>到货地址：'+address[0]+'</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>'+address[1]+'</p></div></div><hr><div style="font-size:15px">');
                            for (var i = 0; i < json.data.fruits.length; i++) {
                                var oo = json.data.fruits[i];
                                $('#jycg144').append('<div class="ui-grid-b"style="width:300px"><div class="ui-block-a"style="margin-top:10px"><span>'+oo.fruitName+oo.quantity+oo.util+'</span></div><div class="ui-block-b"style="margin-top:10px;margin-left:-40px">价格：</div><div class="ui-block-c"style="margin-left:-50px;margin-top:10px">'+oo.totalPrice+'元</div></div><span>要求：'+oo.comment+'</span><br><br>');
                            }
                            $('#jycg144').append('<span>实际水果'+o.fruitTotalPrice+'元</span><br><span>运费'+o.shipPrice+'元</span><br><span>实际总价'+o.totalPrice+'元</span><br><span>发货后交易失败率'+o.customerOrderFail+'</span><br></div></div>');
                            changePage('#page_1_4_4');
                        } else {
                            alert(json.msg)
                        }
                    },
                    eFunc: function(XMLHttpRequest, textStatus, emessage) {
                        alert("未知错误")
                    }
                })
            }

            function go145(id, flag) {
                var flag = false;
                for (var i = 0; i < jycgsb.length; i++) {
                    var o = jycgsb[i];
                    if (o.orderId == id) {
                        flag = true;
                        break;
                    }
                }
                if (!flag) {
                    alert("不存在该订单");
                    return;
                }

                JKjsonP({
                    ws: "merchants/getOrderDetail",
                    parameter: {
                        orderId: id
                    },
                    sFunc: function(json) {
                        if (json.result == "success") {
                            var o = json.data;
                            var address = o.address.split(' ');
                            $('#jysb144').html('<div class="ui-grid-a"><div class="ui-block-a"style="font-size:15px;width:auto"><p style="font-size:18px">'+(true == flag ? '交易成功' : '交易失败')+'</p></div><div class="ui-block-a"style="font-size:15px;width:auto"><p>订单号：'+o.orderNo+'</p></div><div class="ui-block-b"align="right"style="font-size:15px;"><p>预计：'+o.totalPrice+'元</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>下单时间：'+o.dateCreated+'</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>到货时间：'+o.arrivalStartTime+'点-'+o.arrivalEndTime+'点</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>手机号：'+o.mobilePhone+'</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>到货地址：'+address[0]+'</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>'+address[1]+'</p></div></div><hr><div style="font-size:15px">');
                            for (var i = 0; i < json.data.fruits.length; i++) {
                                var oo = json.data.fruits[i];
                                $('#jysb144').append('<div class="ui-grid-b"style="width:300px"><div class="ui-block-a"style="margin-top:10px"><span>'+oo.fruitName+oo.quantity+oo.util+'</span></div><div class="ui-block-b"style="margin-top:10px;margin-left:-40px">价格：</div><div class="ui-block-c"style="margin-left:-50px;margin-top:10px">'+oo.totalPrice+'元</div></div><span>要求：'+oo.comment+'</span><br><br>');
                            }
                            $('#jysb144').append('<span>实际水果'+o.fruitTotalPrice+'元</span><br><span>运费'+o.shipPrice+'元</span><br><span>实际总价'+o.totalPrice+'元</span><br><span>发货后交易失败率'+o.customerOrderFail+'</span><br></div></div>');
                            changePage('#page_1_4_5');
                        } else {
                            alert(json.msg)
                        }
                    },
                    eFunc: function(XMLHttpRequest, textStatus, emessage) {
                        alert("未知错误")
                    }
                })
            }

            function go221(id) {
                $('#page_2_2_1_content').html('');
                JKjsonP({
                    ws: "merchants/getOrderDetail",
                    parameter: {
                        orderId: id
                    },
                    sFunc: function(json) {
                        if (json.result == "success") {
                            var hasFound = false;
                            var obj = json.data;
                            var shop = null;
                            for (var i = 0; i < arr.length; i++) {
                                for (var j = 0; j < arr[i].length; j++) {
                                    if (arr[i][j].orderId == id) {
                                        hasFound = true;
                                        shop = arr[i][j];
                                        break
                                    }
                                }
                                if (hasFound) {
                                    break
                                }
                            }
                            if (!hasFound) {
                                alert("未知错误");
                                return
                            }
                            var tmpTotalFruit = 0;
                            var tmpTotalShip = 0;
							var address = obj.address.split(' ');
                            $('#page_2_2_1_content').html('<div class="ui-grid-a"><div class="ui-block-a"style="font-size:15px;width:auto"><p style="font-size:18px">' + shop.shipStartTime + '点-' + shop.shipEndTime + '点</p></div><div class="ui-block-b"align="right"style="margin-left:60px"><p style="font-size:18px;">' + strArr[shop.status - 1] + '</p></div><div class="ui-block-a"style="font-size:15px;width:auto"><p>订单号：' + obj.orderNo + '</p></div><div class="ui-block-b"align="right"style="font-size:15px;"><p>价格：' + obj.totalPrice + '元</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>下单时间：' + obj.dateCreated + '</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>到货时间：' + obj.arrivalStartTime + '点-' + obj.arrivalEndTime + '点</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>手机号：' + obj.mobilePhone + '</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>到货地址：' + address[0] + '</p></div><div class="ui-block-a"style="font-size:15px;width:auto;margin-top:-30px"><p>' + address[1] + '</p></div></div><hr><div style="font-size:15px">');
                            if (obj.fruits && obj.fruits.length > 0) {
                                for (var i = 0; i < obj.fruits.length; i++) {
                                    var o = obj.fruits[i];
                                    $('#page_2_2_1_content').append('<div class="ui-grid-b"style="width:300px"><div class="ui-block-a"style="margin-top:10px"><span>' + o.fruitName + o.quantity + o.util + '</span></div><div class="ui-block-b"style="margin-top:10px;margin-left:-40px">价格：</div><div class="ui-block-c"style="margin-left:-50px;margin-top:10px">' + o.totalPrice + '元</div></div><span>要求：' + o.comment + '</span><br><br>')
                                }
                            }
                            $('#page_2_2_1_content').append('<span>实际水果' + obj.fruitTotalPrice + '元</span><br><span>运费' + obj.shipPrice + '元</span><br><span>实际总价' + obj.totalPrice + '元</span><br><span>发货后交易失败率' + obj.customerOrderFail + '</span><br></div>');
                            if (obj.status - 1 == 2 || parseInt(obj.arrivalStartTime.split(':')[0]) < new Date().getHours()) {
                                $('#page_2_2_1_content').append('<div class="ui-grid-a"><div class="ui-block-a"><a href="javascript:void(0)" onClick="accept(' + id + ')" data-role="button"style="background-color:#55C3F1">交易成功</a></div><div class="ui-block-b"><a href="javascript:void(0)" onClick="reject(' + id + ')" data-role="button"style="background-color:#55C3F1">拒收</a></div></div>');
                            }
                            changePage('#page_2_2_1')
                        } else {
                            alert(json.msg)
                        }
                    },
                    eFunc: function(XMLHttpRequest, textStatus, emessage) {
                        alert("未知错误")
                    }
                })
            }

            // 计算送货顺序
            function jisuan() {
                if (arr[1] != null && arr[1].length > 0) {
                    var hasOrder = false;

                    var currentTime = new Date().getHours();

                    var sendStr = '';
                    var token = '';

                    for (var i = 0; i < arr[1].length; i++) {
                        if (arr[1][i].shipStartTime == currentTime) {
                            sendStr += token + arr[1][i].orderId;
                            token = ',';
                            hasOrder = true;
                        }
                    }

                    if (hasOrder) {
                        JKjsonP({
                            ws: "merchants/deliverOrder",
                            parameter: {
                                id: sendStr
                            },
                            sFunc: function(json) {
                                if (json.result == "success") {
                                    go212();
                                } else {
                                    alert(json.msg);
                                }
                            },
                            eFunc: function(XMLHttpRequest, textStatus, emessage) {
                                alert("未知错误");
                            }
                        });
                    } else {
                        alert('本小时无可送货的订单');
                    }
                } else {
                    alert('无可送货的订单');
                }
            }

            function accept(id) {
                JKjsonP({
                    ws: "merchants/receiveOrder",
                    parameter: {
                        orderId: id
                    },
                    sFunc: function(json) {
                        if (json.result == "success") {
                            alert(json.msg);
                            go212();
                            changePage('#page_2_1_2');
                        } else {
                            alert(json.msg);
                        }
                    },
                    eFunc: function(XMLHttpRequest, textStatus, emessage) {
                        alert("未知错误");
                    }
                });
            }

            function reject(id) {
                JKjsonP({
                    ws: "merchants/rejectOrder",
                    parameter: {
                        orderId: id
                    },
                    sFunc: function(json) {
                        if (json.result == "success") {
                            alert(json.msg);
                            go212();
                            changePage('#page_2_1_2');
                        } else {
                            alert(json.msg);
                        }
                    },
                    eFunc: function(XMLHttpRequest, textStatus, emessage) {
                        alert("未知错误");
                    }
                });
            }
        </script>
    </head>
    
    <body>
        <div data-role="page" id="page_2_1_2" data-theme="d">
            <div data-role="header">
                <h1 class="ui-corner-all">
                    推荐送货顺序
                </h1>
                 <a  class="ui-btn ui-corner-all ui-btn-right"  onClick="panel()" data-transition="slide" style="margin-right:33px; background-color:#55C3F1">菜单</a> 
            </div>
            <div data-role="content">
                <ul data-role="listview" id="page_2_1_2_list">
                </ul>
            </div>
        </div>
        <div data-role="page" id="page_2_1_1" data-theme="d">
            <div data-role="header">
                <h1 class="ui-corner-all">
                    推荐送货顺序
                </h1>
                 <a  class="ui-btn ui-corner-all ui-btn-right"  onClick="panel()" data-transition="slide" style="margin-right:33px; background-color:#55C3F1">菜单</a> 
            </div>
            <div data-role="content">
                <ul data-role="listview">
                    <li data-role="list-divider">
                        <div class="ui-grid-a">
                            <div class="ui-block-a" align="left">
                                <a style=" font-size:16px; color:#00547b;">
                                    刷新
                                </a>
                            </div>
                            <div class="ui-block-b" align="right">
                                <a style="color:#999; font-size:16px;">
                                    计算送货顺序
                                </a>
                            </div>
                        </div>
                    </li>
                    <li data-role="list-divider">
                        <div style="overflow:hidden;">
                            <div class="ui-grid-a">
                                <div class="ui-block-a" align="left">
                                    <h2>
                                        1点-2点
                                    </h2>
                                </div>
                                <div class="ui-block-b" align="right">
                                    <h2 style="color:#00CC66">
                                        推荐送货顺序
                                    </h2>
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <a href="#page_2_2_1" data-transition="slide">
                            <div class="ui-grid-a" style="font-size:20px">
                                <div class="ui-block-a">
                                    <p>
                                        到货时间：1点-2点
                                    </p>
                                </div>
                                <div class="ui-block-b" align="right">
                                    <p>
                                        价格28元
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        到货地址：梅园三村
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        福山路111弄24号101室
                                    </p>
                                </div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="#page_2_2_1" data-transition="slide">
                            <div class="ui-grid-a" style="font-size:20px">
                                <div class="ui-block-a">
                                    <p>
                                        到货时间：1点-2点
                                    </p>
                                </div>
                                <div class="ui-block-b" align="right">
                                    <p>
                                        价格28元
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        到货地址：梅园三村
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        福山路111弄24号101室
                                    </p>
                                </div>
                            </div>
                        </a>
                    </li>
                    <li data-role="list-divider">
                        <div style="overflow:hidden;">
                            <div class="ui-grid-a">
                                <div class="ui-block-a" align="left">
                                    <h2>
                                        1点-2点
                                    </h2>
                                </div>
                                <div class="ui-block-b" align="right">
                                    <h2 style="color:#00CC66">
                                        可发货
                                    </h2>
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <a href="#page_2_2_1" data-transition="slide">
                            <div class="ui-grid-a" style="font-size:20px">
                                <div class="ui-block-a">
                                    <p>
                                        到货时间：1点-2点
                                    </p>
                                </div>
                                <div class="ui-block-b" align="right">
                                    <p>
                                        价格28元
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        到货地址：梅园三村
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        福山路111弄24号101室
                                    </p>
                                </div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="#page_2_2_1" data-transition="slide">
                            <div class="ui-grid-a" style="font-size:20px">
                                <div class="ui-block-a">
                                    <p>
                                        到货时间：1点-2点
                                    </p>
                                </div>
                                <div class="ui-block-b" align="right">
                                    <p>
                                        价格28元
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        到货地址：梅园三村
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        福山路111弄24号101室
                                    </p>
                                </div>
                            </div>
                        </a>
                    </li>
                    <li data-role="list-divider">
                        <div style="overflow:hidden;">
                            <div class="ui-grid-a">
                                <div class="ui-block-a" align="left">
                                    <h2>
                                        1点-2点
                                    </h2>
                                </div>
                                <div class="ui-block-b" align="right">
                                    <h2 style="color:#00CC66">
                                        队列中
                                    </h2>
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <a href="#page_2_2_2" data-transition="slide">
                            <div class="ui-grid-a" style="font-size:20px">
                                <div class="ui-block-a">
                                    <p>
                                        到货时间：1点-2点
                                    </p>
                                </div>
                                <div class="ui-block-b" align="right">
                                    <p>
                                        价格28元
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        到货地址：梅园三村
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        福山路111弄24号101室
                                    </p>
                                </div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="#page_2_2_2" data-transition="slide">
                            <div class="ui-grid-a" style="font-size:20px">
                                <div class="ui-block-a">
                                    <p>
                                        到货时间：1点-2点
                                    </p>
                                </div>
                                <div class="ui-block-b" align="right">
                                    <p>
                                        价格28元
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        到货地址：梅园三村
                                    </p>
                                </div>
                                <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                    <p>
                                        福山路111弄24号101室
                                    </p>
                                </div>
                            </div>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <div data-role="page" id="page_2_2_1" data-theme="jk">
            <div data-role="header">
                <a class="ui-btn ui-corner-all" data-rel="back" data-icon="back">
                    返回
                </a>
                <h1 class="ui-corner-all">
                    配送中
                </h1>
                 <a  class="ui-btn ui-corner-all ui-btn-right"  onClick="panel()" data-transition="slide" style="margin-right:33px; background-color:#55C3F1">菜单</a> 
            </div>
            <div data-role="content" id="page_2_2_1_content">
            </div>
        </div>
        <div data-role="page" id="page_2_2_2" data-theme="jk">
            <div data-role="header">
                <a class="ui-btn ui-corner-all" data-rel="back" data-icon="back">
                    返回
                </a>
                <h1 class="ui-corner-all">
                    可发货
                </h1>
            </div>
            <div data-role="content">
                <div class="ui-grid-a">
                    <div class="ui-block-a" style="font-size:15px;width:auto">
                        <p style="font-size:18px">
                            1点-2点
                        </p>
                    </div>
                    <div class="ui-block-b" align="right" style="margin-left:70px">
                        <p style="font-size:18px;margin-right:10px">
                            配送中
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto">
                        <p>
                            订单号：20081010
                        </p>
                    </div>
                    <div class="ui-block-b" align="right" style="font-size:15px;">
                        <p>
                            价格：80元
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            下单时间：12：30
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            到货时间：2点-3点
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            手机号：13600000000
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            到货地址：港汇广场
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            福山路111弄24号101室
                        </p>
                    </div>
                </div>
                <hr>
                <div style="font-size:15px">
                    <div class="ui-grid-b" style="width:300px">
                        <div class="ui-block-a" style="margin-top:10px">
                            <span>
                                苹果5斤
                            </span>
                        </div>
                        <div class="ui-block-b" style="margin-top:10px;margin-left:-40px">
                            价格：
                        </div>
                        <div class="ui-block-c" style="margin-left:-50px;margin-top:10px">
                            20元
                        </div>
                    </div>
                    <span>
                        要求：脆一点
                    </span>
                    <br>
                    <br>
                    <div class="ui-grid-b" style="width:300px">
                        <div class="ui-block-a" style="margin-top:10px">
                            <span>
                                菠萝5斤
                            </span>
                        </div>
                        <div class="ui-block-b" style="margin-top:10px;margin-left:-40px">
                            价格：
                        </div>
                        <div class="ui-block-c" style="margin-left:-50px;margin-top:10px">
                            20元
                        </div>
                    </div>
                    <span>
                        要求：甜一点
                    </span>
                    <br>
                    <br>
                    <div class="ui-grid-b" style="width:300px">
                        <div class="ui-block-a" style="margin-top:10px">
                            <span>
                                西瓜1个
                            </span>
                        </div>
                        <div class="ui-block-b" style="margin-top:10px;margin-left:-40px">
                            价格：
                        </div>
                        <div class="ui-block-c" style="margin-left:-50px;margin-top:10px">
                            35元
                        </div>
                    </div>
                    <span>
                        要求：甜一点
                    </span>
                    <br>
                    <br>
                    <span>
                        实际水果75元
                    </span>
                    <br>
                    <span>
                        运费5元
                    </span>
                    <br>
                    <span>
                        实际总价80元
                    </span>
                    <br>
                    <span>
                        发货后交易失败率0%
                    </span>
                    <br>
                </div>
            </div>
        </div>
        <div data-role="page" id="page_1_4_2" data-theme="jk">
            <div data-role="header">
                <a class="ui-btn ui-corner-all" data-rel="back" data-icon="back">
                    返回
                </a>
                <h1 class="ui-corner-all">
                    今日送货明细
                </h1>
                 <a  class="ui-btn ui-corner-all ui-btn-right"  onClick="panel()" data-transition="slide" style="margin-right:33px; background-color:#55C3F1">菜单</a> 
            </div>
            <div data-role="content">
                <div data-role="collapsible-set" style="width: 110%; color:#f00;border:none;"
                data-inset="false">
                    <div data-role="collapsible" style="border:solid 1px #fff;color:#f00;border:none;"
                    align="left">
                        <h1>
                            交易成功
                        </h1>
                        <ul data-role="listview" id="jycgList">
                            <li>
                                <a href="#page_1_4_4" data-transition="slide">
                                    <div class="ui-grid-a" style="font-size:20px;">
                                        <div class="ui-block-a">
                                            <p>
                                                到货时间：1点-2点
                                            </p>
                                        </div>
                                        <div class="ui-block-b" align="right">
                                            <p>
                                                预计28元
                                            </p>
                                        </div>
                                        <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                            <p>
                                                到货地址：梅园三村
                                            </p>
                                        </div>
                                        <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                            <p>
                                                福山路111弄24号101室
                                            </p>
                                        </div>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a href="#page_1_4_4" data-transition="slide">
                                    <div class="ui-grid-a" style="font-size:20px">
                                        <div class="ui-block-a">
                                            <p>
                                                到货时间：1点-2点
                                            </p>
                                        </div>
                                        <div class="ui-block-b" align="right">
                                            <p>
                                                预计28元
                                            </p>
                                        </div>
                                        <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                            <p>
                                                到货地址：梅园三村
                                            </p>
                                        </div>
                                        <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                            <p>
                                                福山路111弄24号101室
                                            </p>
                                        </div>
                                    </div>
                                </a>
                            </li>
                        </ul>
                    </div>
                    <div data-role="collapsible">
                        <h1>
                            交易失败
                        </h1>
                        <ul data-role="listview" id="jysbList">
                            <li>
                                <a href="#page_1_4_5" data-transition="slide">
                                    <div class="ui-grid-a" style="font-size:20px">
                                        <div class="ui-block-a">
                                            <p>
                                                到货时间：1点-2点
                                            </p>
                                        </div>
                                        <div class="ui-block-b" align="right">
                                            <p>
                                                预计28元
                                            </p>
                                        </div>
                                        <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                            <p>
                                                到货地址：梅园三村
                                            </p>
                                        </div>
                                        <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                            <p>
                                                福山路111弄24号101室
                                            </p>
                                        </div>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a href="#page_1_4_5" data-transition="slide">
                                    <div class="ui-grid-a" style="font-size:20px">
                                        <div class="ui-block-a">
                                            <p>
                                                到货时间：1点-2点
                                            </p>
                                        </div>
                                        <div class="ui-block-b" align="right">
                                            <p>
                                                预计28元
                                            </p>
                                        </div>
                                        <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                            <p>
                                                到货地址：梅园三村
                                            </p>
                                        </div>
                                        <div class="ui-block-a" style="width:auto;margin-top:-20px">
                                            <p>
                                                福山路111弄24号101室
                                            </p>
                                        </div>
                                    </div>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <div data-role="page" id="page_1_4_4" data-theme="jk">
            <div data-role="header">
                <a class="ui-btn ui-corner-all" data-rel="back" data-icon="back">
                    返回
                </a>
                <h1 class="ui-corner-all">
                    今日送货明细
                </h1>
                 <a  class="ui-btn ui-corner-all ui-btn-right"  onClick="panel()" data-transition="slide" style="margin-right:33px; background-color:#55C3F1">菜单</a> 
            </div>
            <div data-role="content" id="jycg144">
                <div class="ui-grid-a">
                    <div class="ui-block-a" style="font-size:15px;width:auto">
                        <p style="font-size:18px">
                            交易成功
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto">
                        <p>
                            订单号：20081010
                        </p>
                    </div>
                    <div class="ui-block-b" align="right" style="font-size:15px;">
                        <p>
                            预计：80元
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            下单时间：12：30
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            到货时间：2点-3点
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            手机号：13600000000
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            到货地址：港汇广场
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            福山路111弄24号101室
                        </p>
                    </div>
                </div>
                <hr>
                <div style="font-size:15px">
                    <div class="ui-grid-b" style="width:300px">
                        <div class="ui-block-a" style="margin-top:10px">
                            <span>
                                苹果5斤
                            </span>
                        </div>
                        <div class="ui-block-b" style="margin-top:10px;margin-left:-40px">
                            价格：
                        </div>
                        <div class="ui-block-c" style="margin-left:-50px;margin-top:10px">
                            20元
                        </div>
                    </div>
                    <span>
                        要求：脆一点
                    </span>
                    <br>
                    <br>
                    <div class="ui-grid-b" style="width:300px">
                        <div class="ui-block-a" style="margin-top:10px">
                            <span>
                                菠萝5斤
                            </span>
                        </div>
                        <div class="ui-block-b" style="margin-top:10px;margin-left:-40px">
                            价格：
                        </div>
                        <div class="ui-block-c" style="margin-left:-50px;margin-top:10px">
                            20元
                        </div>
                    </div>
                    <span>
                        要求：甜一点
                    </span>
                    <br>
                    <br>
                    <div class="ui-grid-b" style="width:300px">
                        <div class="ui-block-a" style="margin-top:10px">
                            <span>
                                西瓜1个
                            </span>
                        </div>
                        <div class="ui-block-b" style="margin-top:10px;margin-left:-40px">
                            价格：
                        </div>
                        <div class="ui-block-c" style="margin-left:-50px;margin-top:10px">
                            35元
                        </div>
                    </div>
                    <span>
                        要求：甜一点
                    </span>
                    <br>
                    <br>
                    <span>
                        实际水果75元
                    </span>
                    <br>
                    <span>
                        运费5元
                    </span>
                    <br>
                    <span>
                        实际总价80元
                    </span>
                    <br>
                    <span>
                        发货后交易失败率0%
                    </span>
                    <br>
                </div>
            </div>
        </div>
        <div data-role="page" id="page_1_4_5" data-theme="jk">
            <div data-role="header">
                <a class="ui-btn ui-corner-all" data-rel="back" data-icon="back">
                    返回
                </a>
                <h1 class="ui-corner-all">
                    今日送货明细
                </h1>
                 <a  class="ui-btn ui-corner-all ui-btn-right"  onClick="panel()" data-transition="slide" style="margin-right:33px; background-color:#55C3F1">菜单</a> 
            </div>
            <div data-role="content" id="jysb144">
                <div class="ui-grid-a">
                    <div class="ui-block-a" style="font-size:15px;width:auto">
                        <p style="font-size:18px">
                            交易失败
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto">
                        <p>
                            订单号：20081010
                        </p>
                    </div>
                    <div class="ui-block-b" align="right" style="font-size:15px;">
                        <p>
                            预计：80元
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            下单时间：12：30
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            到货时间：2点-3点
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            手机号：13600000000
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            到货地址：港汇广场
                        </p>
                    </div>
                    <div class="ui-block-a" style="font-size:15px;width:auto;margin-top:-30px">
                        <p>
                            福山路111弄24号101室
                        </p>
                    </div>
                </div>
                <hr>
                <div style="font-size:15px">
                    <div class="ui-grid-b" style="width:300px">
                        <div class="ui-block-a" style="margin-top:10px">
                            <span>
                                苹果5斤
                            </span>
                        </div>
                        <div class="ui-block-b" style="margin-top:10px;margin-left:-40px">
                            价格：
                        </div>
                        <div class="ui-block-c" style="margin-left:-50px;margin-top:10px">
                            20元
                        </div>
                    </div>
                    <span>
                        要求：脆一点
                    </span>
                    <br>
                    <br>
                    <div class="ui-grid-b" style="width:300px">
                        <div class="ui-block-a" style="margin-top:10px">
                            <span>
                                菠萝5斤
                            </span>
                        </div>
                        <div class="ui-block-b" style="margin-top:10px;margin-left:-40px">
                            价格：
                        </div>
                        <div class="ui-block-c" style="margin-left:-50px;margin-top:10px">
                            20元
                        </div>
                    </div>
                    <span>
                        要求：甜一点
                    </span>
                    <br>
                    <br>
                    <div class="ui-grid-b" style="width:300px">
                        <div class="ui-block-a" style="margin-top:10px">
                            <span>
                                西瓜1个
                            </span>
                        </div>
                        <div class="ui-block-b" style="margin-top:10px;margin-left:-40px">
                            价格：
                        </div>
                        <div class="ui-block-c" style="margin-left:-50px;margin-top:10px">
                            35元
                        </div>
                    </div>
                    <span>
                        要求：甜一点
                    </span>
                    <br>
                    <br>
                    <span>
                        实际水果75元
                    </span>
                    <br>
                    <span>
                        运费5元
                    </span>
                    <br>
                    <span>
                        实际总价80元
                    </span>
                    <br>
                    <span>
                        发货后交易失败率0%
                    </span>
                    <br>
                </div>
            </div>
        </div>
        <div data-role="panel" id="leftpanel" data-position="right" data-display="reveal"
        data-theme="jk">
            <ul data-role="listview">
                <li>
                    <a href="#page_2_1_2" data-transition="slide" class="ui-btn" onClick="javascript:samePageID('#page_2_1_2');"
                    style="background-color:#54c3f1;color:#FFFFFF">
                        推荐送货顺序
                    </a>
                </li>
                <li>
                    <a href="javascript:void(0);" data-transition="slide" class="ui-btn" onClick="go142()"
                    style="background-color:#54c3f1;color:#FFFFFF">
                        今日送货明细
                    </a>
                </li>
                <li><a  class="ui-btn"  style="background-color:#54c3f1;color:#FFFFFF" onClick="reLogin()">退出</a></li>
            </ul>
        </div>
        <script>
		function panel(){
	if($("#leftpanel").open){
		$( "#leftpanel" ).panel( "close" );
	}else{
	$( "#leftpanel" ).panel( "open" );
	}
}
            function reLogin() {
				var status12 = 0;
				var status3 = 0;
                JKjsonP({
                    ws: "merchants/listDeliveryOrder2",
                    parameter: {
                        id: localStorage.getItem("subAdminId")
                    },
                    sFunc: function(json) {
                        if(json.result == "success"){
							for(var i = 0;i<json.data.length;i++){
								var status = json.data[i].status;
									if(status == "1"||status == "2"){
										status12 ++;
									}
									if(status == "3"){
										status3 ++;
									}
							}
							
							if(status12<=2&&status3 ==0){
								 localStorage.clear();
								 localStorage.setItem("telPhones",window.telArr);
								JKjsonP({
									ws:"merchants/subAdminLogout",
									parameter:{id:window.subAdminId},
									sFunc:function(json){
										if(json.result=="success"){
											top.location="index.html";
										}
									},
									eFunc:function(XMLHttpRequest, textStatus, emessage){
										alert(emessage);
									}
								});		
							}else{
								alert("剩余订单过多，请处理后再退出");
							}
						}
						

                    },
                    eFunc: function(XMLHttpRequest, textStatus, emessage) {
                        alert("未知错误");
                        $('#shuaxin').bind('click',
                        function() {
                            $('#shuaxin').trigger('create');
                            go212();
                        }).css('color', '#00CC66');
                    }
                });
               
                
            }
           
            var currentPageID = "#page_2_1_2";
            $(function() {
                $(document).on("swipeleft",
                function(event) {
                    $("#leftpanel").panel("open");
                });
                $(document).on("swiperight",
                function(event) {
                    $("#leftpanel").panel("close");
                });
            });
            function samePageID(newPageID) {
                if (currentPageID == newPageID) {
                    $(":jqmData(role='panel')").panel('close');
                } else {
                    currentPageID = newPageID;
                }
            }
        </script>
        <script id="panel-init">
            $(function() {
                $("body>[data-role='panel']").panel();
            });
        </script>
    </body>

</html>